# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=openmdao
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
         "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=1.7.1
pkgrel=1
pkgdesc="An open-source MDAO framework written in Python. (mingw-w64)"
arch=('any')
license=('apache')
url="http://openmdao.org/"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("OpenMDAO-${pkgver}.tar.gz::https://github.com/OpenMDAO/OpenMDAO/archive/${pkgver}.tar.gz")
sha256sums=('b4084f4f42c03f521c641d27f81aaada763b86c7af13b578d91196afa7d9bfd1')


prepare() {
  cp -a OpenMDAO-${pkgver}{,-py2}
}

build() {
  cd ${srcdir}/OpenMDAO-${pkgver}
  python3 setup.py build

  cd ${srcdir}/OpenMDAO-${pkgver}-py2
  python2 setup.py build
}

#check() {
#  cd ${srcdir}/OpenMDAO-${_realname}-${pkgver}
#  nosetests-3.5
#
#  cd ${srcdir}/OpenMDAO-${_realname}-${pkgver}-py2
#  nosetests-2.7
#}

package_python3-openmdao() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python3-numpy>=1.9.2"
    "${MINGW_PACKAGE_PREFIX}-python3-scipy"
    "${MINGW_PACKAGE_PREFIX}-python3-networkx>=1.9.1"
    "${MINGW_PACKAGE_PREFIX}-python3-sqlitedict"
    "${MINGW_PACKAGE_PREFIX}-python3-pyparsing"
    "${MINGW_PACKAGE_PREFIX}-python3-six"
  )

  cd OpenMDAO-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -D -m644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-openmdao() {
  depends=(
    "${MINGW_PACKAGE_PREFIX}-python2-numpy>=1.9.2"
    "${MINGW_PACKAGE_PREFIX}-python2-scipy"
    "${MINGW_PACKAGE_PREFIX}-python2-networkx>=1.9.1"
    "${MINGW_PACKAGE_PREFIX}-python2-sqlitedict"
    "${MINGW_PACKAGE_PREFIX}-python2-pyparsing"
    "${MINGW_PACKAGE_PREFIX}-python2-six"
  )

  cd OpenMDAO-${pkgver}-py2
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -D -m644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-openmdao() {
  package_python2-openmdao
}

package_mingw-w64-i686-python3-openmdao() {
  package_python3-openmdao
}

package_mingw-w64-x86_64-python2-openmdao() {
  package_python2-openmdao
}

package_mingw-w64-x86_64-python3-openmdao() {
  package_python3-openmdao
}

# vim:set ts=2 sw=2 et:
